    import Vue from 'vue'
    import Vuex from 'vuex'
    import VuexPersist from 'vuex-persist'



    const vuexLocal = new VuexPersist({
        storage: window.localStorage //可选，sessionStorage/indexDB  // 你的储存方式
      });
    Vue.use(Vuex); export default new Vuex.Store({
        state: {
            arrnew: [
                { name: "推荐" },
                { name: "折扣" },
                { name: "特色中份菜" },
                { name: "大份菜" },
                { name: "炖菜.汤菜" },
                { name: "鱼" },
                { name: "凉菜" },
                { name: "主食" },
                { name: "饮品" },
            ],
            arr: [
                {
                    pic: "https://i02piccdn.sogoucdn.com/e60edb7efe0ad3a3",
                    title: "牛排",
                    xl: 1,
                    ys: 68,
                    zk: "9.8折",
                    f: 1,
                    price: 188,
                    by: 288,
                    chuxian: false,
                    n: 0,

                },
                {
                    pic: "https://i02piccdn.sogoucdn.com/dc4bca3aca5ad0d3",
                    title: "香辣猪蹄",
                    xl: 2,
                    ys: 30,
                    zk: "9.8折",
                    f: 1,
                    price: 99,
                    by: 199,
                    chuxian: false,
                    n: 0,

                },
                {
                    pic: "https://i02piccdn.sogoucdn.com/2b459923ff24895f",
                    title: "寿司",
                    xl: 3,
                    ys: 500,
                    zk: "9.5折",
                    f: 1,
                    price: 30,
                    by: 58.8,
                    chuxian: false,
                    n: 0,

                },
                {
                    pic: "https://i01piccdn.sogoucdn.com/be25dc6205964ceb",
                    title: "便当",
                    xl: 2,
                    ys: 1000,
                    zk: "9.5折",
                    f: 1,
                    price: 29.9,
                    by: 38.8,
                    chuxian: false,
                    n: 0,
                },
            ],
            zongshu: 0,
            zongjia: 0,
        },
        mutations: {
            setN(item, zhi) {
                this.state.arr[zhi].n++
                this.state.zongshu++
                if (this.state.arr[zhi].n == 1) {
                    this.state.arr[zhi].chuxian =true
                }
            },
            setM(item, zhi) {
                this.state.arr[zhi].n--
                this.state.zongshu--
                if (this.state.arr[zhi].n == 0) {
                    this.state.arr[zhi].chuxian =false
                }
            },
        },
        getters: {
            getsum(state) {
                var sum = 0
                state.arr.forEach(item => {
                    sum += item.price * item.n
                })
                return sum
            }
        },
    plugins: [vuexLocal.plugin]

    })